package com.fshuqing.learing.spring.applicationcontext;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @author fshuqing
 * 注意
 * 1、构造函数只能有一个，如果有多个的话，就必须有一个无参构造函数，此时，spring会调用无参的构造函数
 * 2、构造函数的参数必须都要在spring容器中有，如构造函数有2个参数
 *  public ThreeApplicationContext(ApplicationContext applicationContext, User user) {
        this.applicationContext = applicationContext;
        this.user = user;
    }， 此时必须在spring容器中可以获得User对象
 */
@Component
public class ThreeApplicationContext {

    private ApplicationContext applicationContext;

    public ThreeApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    public void show() {
        System.out.println("ThreeApplicationContext = " + applicationContext);
    }
}
